#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
using namespace std;
int Next[1000010];
vector<int>match_point;
void get_Next(string s)
{
    Next[0]=0;
    int j=0;
    int len=s.length();
    for(int i=1;i<len;i++)
    {
        while(j>0&&s[i]!=s[j])j=Next[j-1];
        if(s[i]==s[j])j++;
        Next[i]=j;
    }
}
void kmp(string str,string match)
{
    int j=0;
    int n1=str.length();
    int n2=match.length();
    for(int i=0;i<n1;i++)
    {
        while(j>0&&str[i]!=match[j])j=Next[j-1];
        if(str[i]==match[j])j++;
        if(j==n2){
            match_point.push_back(i-n2+1);
        }
    }
}
int main()
{
    //freopen("P3375_1.in","r",stdin);
    //freopen("P3375_1.out","w",stdout);
    string str,match_str;
    cin>>str;
    cin>>match_str;
    get_Next(match_str);
    kmp(str,match_str);
    if(!match_point.empty())
    {
        for(int i=0;i<match_point.size();i++)
        {
            cout<<match_point[i]+1<<endl;
        }
        
    }
    //else cout<<0<<endl;
    for(int i=0;i<match_str.length();i++)cout<<Next[i]<<" ";
    return 0;
}